package com.uvg.camara;

/*
 * Modificado por Luis Jose Pinillos, Roberto Andrino, Ivan Concua, Gabriela Manrique y Jose Roberto Ruano
 * Codigo obtenido de http://nolehagascasoaesostiposelementales.wordpress.com/2008/09/25/grafos-algoritmos-de-floyd-y-warshall/
 * Codigo que calcula el centro de un grafo y devuelve el peso entre dos nodos
 */
        
public class Matriz {      
		
		Graph grafo;
		public Matriz()
		{
			String[] array = new String[15];
	        grafo= new Graph();
	        
			try 
			{
				// se crea el grafo
				array[0]= "A";
                array[1]= "B";
                array[2]= "C";
                array[3]= "Ca";
                array[4] = "C1";
                array[5] = "D";
                array[6]= "E";
                array[7] = "F";
                array[8]="G";
                array[9]="H";
                array[10]="I";
                array[11]= "II 1";
                array [12] = "II 2";
                array[13] = "J";
                array[14]= "K";
                
                for(int x=0;x<array.length;x++)
                    grafo.addVertex(array[x]);
			
				array[0] = "A";
				array[1]= "B";
				array[2]= "132.2";				
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
							
				array[0] = "A";
				array[1]= "C";
				array[2]= "166.8";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
					
				array[0] = "A";
				array[1]= "C1";
				array[2]= "141.0";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "A";
				array[1]= "D";
				array[2]= "166.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "A";
				array[1]= "E";
				array[2]= "87.8";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "A";
				array[1]= "F";
				array[2]= "52.2";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
					
				array[0] = "A";
				array[1]= "H";
				array[2]= "65.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
					
				array[0] = "A";
				array[1]= "II 1";
				array[2]= "56.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "A";
				array[1]= "II 2";
				array[2]= "89.9";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "A";
				array[1]= "J";
				array[2]= "107.2";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "A";
				array[1]= "K";
				array[2]= "56.5";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "B";
				array[1]= "A";
				array[2]= "132.2";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "B";
				array[1]= "C";
				array[2]= "47.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));	
				
				array[0] = "B";
				array[1]= "C1";
				array[2]= "59.5";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "B";
				array[1]= "D";
				array[2]= "60.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "B";
				array[1]= "E";
				array[2]= "52.9";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "B";
				array[1]= "F";
				array[2]= "90.6";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));		
				
				array[0] = "B";
				array[1]= "H";
				array[2]= "138.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));		
				
				array[0] = "B";
				array[1]= "II 1";
				array[2]= "106.8";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "B";
				array[1]= "II 2";
				array[2]= "99.9";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "B";
				array[1]= "J";
				array[2]= "208.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "B";
				array[1]= "K";
				array[2]= "175.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C";
				array[1]= "A";
				array[2]= "166.8";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C";
				array[1]= "B";
				array[2]= "47.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C";
				array[1]= "Ca";
				array[2]= "38.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C";
				array[1]= "C1";
				array[2]= "41.4";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C";
				array[1]= "D";
				array[2]= "19.9";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C";
				array[1]= "E";
				array[2]= "98.4";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C";
				array[1]= "F";
				array[2]= "117.8";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				
				array[0] = "C";
				array[1]= "H";
				array[2]= "154.9";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C";
				array[1]= "II 1";
				array[2]= "151.3";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C";
				array[1]= "II 2";
				array[2]= "147.4";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C";
				array[1]= "J";
				array[2]= "224.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C";
				array[1]= "K";
				array[2]= "200.6";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
			
				array[0] = "Ca";
				array[1]= "C";
				array[2]= "38.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "Ca";
				array[1]= "C1";
				array[2]= "16.6";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
			   
				array[0] = "D";
				array[1]= "A";
				array[2]= "166.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "D";
				array[1]= "B";
				array[2]= "60.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "D";
				array[1]= "C";
				array[2]= "19.9";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
					
				array[0] = "D";
				array[1]= "C1";
				array[2]= "28.6";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "D";
				array[1]= "E";
				array[2]= "93.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "D";
				array[1]= "F";
				array[2]= "89.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));   
				
				array[0] = "D";
				array[1]= "H";
				array[2]= "146.3";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "D";
				array[1]= "II 1";
				array[2]= "157.4";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "D";
				array[1]= "II 2";
				array[2]= "157.5";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "D";
				array[1]= "J";
				array[2]= "215.2";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "D";
				array[1]= "K";
				array[2]= "194.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C1";
				array[1]= "A";
				array[2]= "141.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C1";
				array[1]= "B";
				array[2]= "59.5";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C1";
				array[1]= "C";
				array[2]= "41.4";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C1";
				array[1]= "Ca";
				array[2]= "16.6";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C1";
				array[1]= "D";
				array[2]= "28.6";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C1";
				array[1]= "E";
				array[2]= "93.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C1";
				array[1]= "F";
				array[2]= "89.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
			   
				array[0] = "C1";
				array[1]= "H";
				array[2]= "117.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C1";
				array[1]= "II 1";
				array[2]= "139.3";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C1";
				array[1]= "II 2";
				array[2]= "144.8";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C1";
				array[1]= "J";
				array[2]= "185.9";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C1";
				array[1]= "K";
				array[2]= "166.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "E";
				array[1]= "A";
				array[2]= "87.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "E";
				array[1]= "B";
				array[2]= "52.9";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "E";
				array[1]= "C";
				array[2]= "98.4";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "E";
				array[1]= "C1";
				array[2]= "93.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "E";
				array[1]= "D";
				array[2]= "106.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
								
				array[0] = "E";
				array[1]= "F";
				array[2]= "62.8";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "E";
				array[1]= "H";
				array[2]= "115.2";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "E";
				array[1]= "II 1";
				array[2]= "53.9";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "E";
				array[1]= "II 2";
				array[2]= "51.6";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "E";
				array[1]= "J";
				array[2]= "181.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "E";
				array[1]= "K";
				array[2]= "138.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "F";
				array[1]= "A";
				array[2]= "52.2";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "F";
				array[1]= "B";
				array[2]= "90.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "F";
				array[1]= "C";
				array[2]= "117.8";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				
				array[0] = "F";
				array[1]= "D";
				array[2]= "115.0";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "F";
				array[1]= "E";
				array[2]= "62.8";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "F";
				array[1]= "C1";
				array[2]= "89.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "F";
				array[1]= "G";
				array[2]= "28.4";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
							   
				array[0] = "F";
				array[1]= "II 1";
				array[2]= "71.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "F";
				array[1]= "II 2";
				array[2]= "94.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
							 
				array[0] = "F";
				array[1]= "K";
				array[2]= "84.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "G";
				array[1]= "F";
				array[2]= "28.4";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "G";
				array[1]= "H";
				array[2]= "24.2";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
			   array[0] = "H";
				array[1]= "A";
				array[2]= "65.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "H";
				array[1]= "B";
				array[2]= "138.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "H";
				array[1]= "C";
				array[2]= "154.9";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "H";
				array[1]= "D";
				array[2]= "146.3";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "H";
				array[1]= "E";
				array[2]= "115.2";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "H";
				array[1]= "G";
				array[2]= "24.2";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "H";
				array[1]= "I";
				array[2]= "35.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "H";
				array[1]= "II 1";
				array[2]= "112.2";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "H";
				array[1]= "II 2";
				array[2]= "141.3";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "H";
				array[1]= "K";
				array[2]= "53.3";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
	
				array[0] = "I";
				array[1]= "H";
				array[2]= "35.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "I";
				array[1]= "J";
				array[2]= "41.8";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 1";
				array[1]= "A";
				array[2]= "56.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 1";
				array[1]= "B";
				array[2]= "106.8";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 1";
				array[1]= "C";
				array[2]= "151.3";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 1";
				array[1]= "D";
				array[2]= "157.4";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 1";
				array[1]= "E";
				array[2]= "53.9";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 1";
				array[1]= "F";
				array[2]= "71.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
			   
				array[0] = "II 1";
				array[1]= "H";
				array[2]= "112.2";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 1";
				array[1]= "C1";
				array[2]= "139.3";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 1";
				array[1]= "II 2";
				array[2]= "33.2";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 1";
				array[1]= "J";
				array[2]= "163.3";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 1";
				array[1]= "K";
				array[2]= "113.2";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 2";
				array[1]= "A";
				array[2]= "89.8";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 2";
				array[1]= "B";
				array[2]= "99.9";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 2";
				array[1]= "C";
				array[2]= "147.4";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 2";
				array[1]= "D";
				array[2]= "157.5";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 2";
				array[1]= "E";
				array[2]= "51.6";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 2";
				array[1]= "F";
				array[2]= "94.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 2";
				array[1]= "H";
				array[2]= "141.3";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
			   
				array[0] = "II 2";
				array[1]= "II 1";
				array[2]= "33.2";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 2";
				array[1]= "C1";
				array[2]= "144.8";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 2";
				array[1]= "J";
				array[2]= "196.3";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "II 2";
				array[1]= "K";
				array[2]= "146.3";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "J";
				array[1]= "A";
				array[2]= "107.2";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "J";
				array[1]= "B";
				array[2]= "208.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "J";
				array[1]= "C";
				array[2]= "224.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
			   
				array[0] = "J";
				array[1]= "D";
				array[2]= "214.6";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "J";
				array[1]= "E";
				array[2]= "181.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "C1";
				array[1]= "I";
				array[2]= "144.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "J";
				array[1]= "II 1";
				array[2]= "163.9";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "J";
				array[1]= "II 2";
				array[2]= "196.3";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "J";
				array[1]= "C1";
				array[2]= "185.9";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "J";
				array[1]= "K";
				array[2]= "52.9";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "K";
				array[1]= "A";
				array[2]= "56.5";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "K";
				array[1]= "B";
				array[2]= "175.1";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "K";
				array[1]= "C";
				array[2]= "200.5";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "K";
				array[1]= "D";
				array[2]= "194.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "K";
				array[1]= "E";
				array[2]= "138.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "K";
				array[1]= "F";
				array[2]= "84.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
			   
				array[0] = "K";
				array[1]= "H";
				array[2]= "53.3";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "K";
				array[1]= "II 1";
				array[2]= "113.2";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "K";
				array[1]= "II 2";
				array[2]= "146.3";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "K";
				array[1]= "J";
				array[2]= "52.9";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				array[0] = "K";
				array[1]= "C1";
				array[2]= "166.7";
				grafo.addEdge(array[0], array[1], Double.parseDouble(array[2]));
				
				grafo.crearMatriz(); // se crea la matriz
				grafo.algoritmoFloyd(); // se ejecuta el algoritmo de Floyd
			} catch(Exception e){}		
		}
         
		// metodo que devuelve el peso entre dos nodos
        public double getWeight(String principio, String fin)
		{
			return grafo.getPeso(principio, fin);
		}

        // metodo que devuelve el centro del grafo
        public String center()
		{
           return grafo.getCenter();
        }
		
        // metodo que devuelve el grafo
		public Graph getGraph()
		{
			return grafo;
		}
}

